package com.lkd.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lkd.entity.TaskEntity;
import com.lkd.entity.TaskStatusTypeEntity;
import com.lkd.http.vo.CancelTaskViewModel;
import com.lkd.http.vo.CollectTaskVo;
import com.lkd.http.vo.TaskReportInfoVO;
import com.lkd.http.vo.TaskViewModel;
import com.lkd.http.vo.UserWorkTopVO;
import com.lkd.vo.Pager;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 工单业务逻辑
 */
public interface TaskService extends IService<TaskEntity> {


    /**
     * 通过条件搜索工单列表
     * @param pageIndex
     * @param pageSize
     * @param innerCode
     * @param userId
     * @param taskCode
     * @param isRepair 是否是运维工单
     * @return
     */
    Pager<TaskEntity> search(Long pageIndex, Long pageSize, String innerCode, Integer userId, String taskCode, Integer status, Boolean isRepair, String start, String end);





    /**
     * 获取所有状态类型
     * @return
     */
    List<TaskStatusTypeEntity> getAllStatus();

    /**
     * <p>Description: 创建工单</p>
     *
     * @author liuyiming
     * @date 2022-12-16 20:26
     * @version 1.0.0
     */
    Boolean createTask(TaskViewModel taskViewModel);

    /**
     * <p>Description: 接收工单</p>
     *
     * @author liuyiming
     * @date 2022-12-16 21:32
     * @version 1.0.0
     */
    boolean acceptTask(long taskId, Integer userId);

    /**
     * <p>Description: 取消工单</p>
     *
     * @author liuyiming
     * @date 2022-12-16 22:19
     * @version 1.0.0
     */
    Boolean cancelTask(long taskId, CancelTaskViewModel cancelTaskViewModel);

    /**
     * <p>Description: 完成工单</p>
     *
     * @author liuyiming
     * @date 2022-12-16 22:28
     * @version 1.0.0
     */
    Boolean completeTask(long taskId);

    /**
     * 获取最少工单量用户
     *
     * @param regionId  区域id
     * @param isSupply  true 运营工单 false 运维工单
     * @return 用户id  if get nothing, return null
     */
    Integer getLeastUser(Long regionId, Boolean isSupply);

    /**
     * 获取当时工单汇总信息
     */
    List<TaskReportInfoVO> taskReportInfo(LocalDateTime start, LocalDateTime end);

    /**
     * 人效排名月度统计
     * @param start
     * @param end
     * @param isRepair
     * @param regionId
     * @return
     */
    List<UserWorkTopVO> userWorkTop10(LocalDate start, LocalDate end, boolean isRepair, long regionId);

    /**
     * 工单状态统计（柱状图）
     * @param startDate
     * @param endDate
     */
    List<CollectTaskVo> collectReport(LocalDate startDate, LocalDate endDate);
}
